function EditorPageView() {
    this.m_edPage = null;
    this.m_width = 0;
    this.m_height = 0; // with scale factor in pixel
    this.m_rcPage = [];//left, top, right, bottom;
    this.m_nPageIndex = -1;
    this.m_bVisible = false;
    this.m_Canvas = null;
    this.m_canvasDiv = null;
    this.m_pageRender = null;
    this.m_dataMgr = null;
    this.m_sPosition = [];
    this.m_textPage = null;
    this.m_textHighLights = null;
    this.m_isLineSelect = 1;
    this.m_stTextInfo = null;
    this.m_selectChar = null;
    this.m_selectTextInfo = [];
    this.m_SLMsgList = [];
    this.m_NeedDrawSLMsgList = [];
    this.m_NeedClearSLMsgList = [];
    this.m_mode = 0;
    this.m_annotList = [];
    this.m_curMatrix = null;
	this.m_pdDoc = null;
	var m_pdPage = null;
	this.rotate = null;
	this.SetPDPage = function(pdPage){
		m_pdPage = pdPage;
	};
	this.GetPDPage = function(){
		return m_pdPage;
	};
}

EditorPageView.prototype.GetTXTPage = function (edPage) { return this.m_textPage; };
EditorPageView.prototype.SetEDPage = function (edPage) { this.m_edPage = edPage; };
EditorPageView.prototype.GetEDPage = function () { return this.m_edPage; };
EditorPageView.prototype.GetPageIndex = function () { return this.m_nPageIndex; };
EditorPageView.prototype.SetPageIndex = function (index) { this.m_nPageIndex = index; };
EditorPageView.prototype.IsVisible = function () { return this.m_bVisible; };
EditorPageView.prototype.SetVisible = function (bVisible) { this.m_bVisible = bVisible; };
EditorPageView.prototype.SetPageRect = function (left, top, right, bottom) {
    this.m_rcPage[0] = left;
    this.m_rcPage[1] = top;
    this.m_rcPage[2] = right;
    this.m_rcPage[3] = bottom;
};
EditorPageView.prototype.GetPageRect = function () { return this.m_rcPage; };
EditorPageView.prototype.CreateCanvas = function (domDiv) {
	var pageWidth = this.m_width;
	var pageHeight = this.m_height;
    this.m_canvasDiv = domDiv;
    var theDiv = this.m_canvasDiv;
    theDiv.style.width = pageWidth + "px";
    theDiv.style.height = pageHeight + "px";
    theDiv.style.position = "relative";
    theDiv.style.overflow = "visible";
    theDiv.style.padding = "0";
    this.m_Canvas = document.createElement("canvas");
    this.m_Canvas.id = "canvas" + this.m_nPageIndex;
    this.m_Canvas.width = pageWidth;
    this.m_Canvas.height = pageHeight;
    this.m_Canvas.className = "ui_new_file";
    theDiv.appendChild(this.m_Canvas);
    return this.m_Canvas;
};

EditorPageView.prototype.Display = function (x, y, nRotate) {
    // after the page data has been downloaded, reset the edPage->pdPage
    //    if (null == this.m_edPage.pdPage) {
    //        this.m_edPage.pdPage = this.m_edViewer.m_edDoc.pdDoc.GetPageByIndex(this.m_nPageIndex);
    //    }
    // release data manager
    this.m_dataMgr = null; //new DataMgr(this.m_pdDoc.docId,this.m_nPageIndex,"GetPageBin.do");
    if (null != this.m_pageRender) {
        //------Modifyed by haipeng_yang---2013-08-31--begin---------------------------
        this.m_pageRender.ClearRect(this.m_Canvas, 0, 0, this.m_width, this.m_height);
        delete this.m_pageRender;
        this.m_pageRender = null;
    }
    var nScale = this.m_width / (this.GetPDPage().GetSize()[0] * 96 / 72);
    var w = this.m_width;
    var h = this.m_height;
    var pdPage = this.GetPDPage();
    // reset the div&canvas width&height
    this.m_canvasDiv.style.width = w + "px";
    this.m_canvasDiv.style.height = h + "px";
    this.m_Canvas.width = w;
    this.m_Canvas.height = h;
    this.rotate = nScale;
    if (navigator.userAgent.indexOf("MSIE") == -1) {
        this.m_mode = 1;
    }

    this.m_curMatrix = pdPage.GetDisplayMatrix(0, 0, w, h, nRotate);
    this.m_pageRender = new PDRenderContext();
    this.m_pageRender.AppandObjList(pdPage.GetPageObjects(), this.m_curMatrix);

    var annots = pdPage.GetAnnotList();
    if (null != annots) {
        annots.ShowAnnots(this.m_pageRender, this.m_curMatrix, true);
    }


    this.m_pageRender.Render(this.m_Canvas, null, null, nScale, this.m_mode);
    
    var filler = new InterFormFiller();
	filler.CreateControl(pdPage,this.m_curMatrix);
};


EditorPageView.prototype.AdjustPageViewSize = function(nRotate, nScale) {
    switch (nRotate) {
		case 0:
		case 2:
			this.m_width = this.m_edPage.GetPageWidth() * 96/72 * nScale;
			this.m_height = this.m_edPage.GetPageHeight() * 96 / 72 * nScale;
		break;
		case 1:
		case 3:
		    this.m_width = this.m_edPage.GetPageHeight() * 96 / 72 * nScale;
		    this.m_height = this.m_edPage.GetPageWidth() * 96 / 72 * nScale;
		break;
	}
	
   	// reset the div&canvas width&height
   	this.m_canvasDiv.style.width = this.m_width + "px";
   	this.m_canvasDiv.style.height = this.m_height + "px";
   	this.m_Canvas.width = this.m_width;
   	this.m_Canvas.height = this.m_height;
   	if (null != this.m_pageRender) {
   		this.m_pageRender.viewScale = nScale; 
   	}
};

